#!/usr/bin/env bash

source ./config/env.sh
clear

echo -e "\033[1;33m ---------------- flanneld --------------------------------\033[0m"
for node_ip in ${NODE_IP}
do
  echo -e "${node_ip}::\c";ssh root@${node_ip} "hostname"
  ssh root@${node_ip} "systemctl status flanneld | grep 'Active:'"
done

echo -e "\033[1;33m ---------------- docker --------------------------------\033[0m"
for node_ip in ${NODE_IP}
do
  echo -e "${node_ip}::\c";ssh root@${node_ip} "hostname"
  ssh root@${node_ip} "systemctl status docker | grep 'Active:'"
done

echo -e "\033[1;33m ---------------- kubelet --------------------------------\033[0m"
for node_ip in ${NODE_IP}
do
  echo -e "${node_ip}::\c";ssh root@${node_ip} "hostname"
  ssh root@${node_ip} "systemctl status kubelet | grep 'Active:'"
done

echo -e "\033[1;33m ---------------- kube-proxy --------------------------------\033[0m"
for node_ip in ${NODE_IP}
do
  echo -e "${node_ip}::\c";ssh root@${node_ip} "hostname"
  ssh root@${node_ip} "systemctl status kube-proxy | grep 'Active:'"
done

${K8S_BIN_DIR}/kubectl cluster-info

${K8S_BIN_DIR}/kubectl get csr | awk '{print $1}' | sed '1d' | xargs kubectl certificate approve